<template>
  <div class="my_main">
    <head-top head-title="我的" hidden='true'></head-top>
    <div class="head">
      <div class="head_bg" :style="'backgroundImage: url('+info.avatar+')'"></div>
      <div class="head_one">
        <img
          :src="info.avatar || 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1651318081,2860235060&fm=27&gp=0.jpg'"
          alt="">
      </div>
      <div class="head_two">
        <span>{{info.nickname}}</span>
      </div>
    </div>
    <mt-cell title="编辑资料" is-link to="/EditData1"></mt-cell>
    <mt-cell title="我的房" is-link to="/my/MyHouse"></mt-cell>
    <mt-cell title="我的投票" is-link to="/my/MyVote"></mt-cell>
    <mt-cell title="我的发布" is-link to="/my/MyIdle"></mt-cell>
    <mt-cell title="我的查验" is-link to="/my/MyCheck"></mt-cell>
    <mt-cell title="业主认证" is-link to="/my/IdentList"></mt-cell>
    <mt-cell title="投票统计" is-link to="/my/Statistics"></mt-cell>
    <mt-cell title="关于我们" is-link to="/my/AboutUs"></mt-cell>
    <mt-cell title="帮助与意见反馈" is-link to="/my/Opinion"></mt-cell>
    <v-footer></v-footer>
  </div>
</template>
<style lang="scss">
  .my_main {
    width: 100%;
    padding-top: 40px;
    padding-bottom: 20%;
    .mint-cell-wrapper {
      background-position: bottom left;
      background-size: 100% 1px;
      .mint-cell-value {
        span {
          color: #398ede;
          font-size: 13px;
        }
      }
    }
    .no-border {
      .mint-cell-wrapper {
        background-size: 100% 0px;
      }
    }
    .head {
      width: 100%;
      height: 122px;
      position: relative;
      .head_bg{
        position: absolute;
        height: 122px;
        width: 100%;
        top: 0px;
        left: 0;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        opacity: 0.2;
      }
      .head_one {
        width: 100%;
        height: 65px;
        padding-top: 20px;
        text-align: center;
        img {
          width: 65px;
          height: 65px;
          border-radius: 50%;
        }
      }
      .head_two {
        width: 100%;
        height: 27px;
        margin-top: 10px;
        text-align: center;
        span {
          font-size: 15px;
        }
        img {
          width: 8px;
          height: 11px;
        }
      }
    }
  }
</style>
<script>
  import headTop from '../header/Header.vue'
  import Footer from '../footer/Footer.vue'
  import bus from '../../common/js/commonvue.js'
  import { getMyInfo } from '../../api/my.js'
  import {
    savePhoneName
  } from '../../common/js/cache.js'

  export default {
    name: 'My',
    data () {
      return {
        realName: '',
        phoneNumber: '',
        info: ''
      }
    },
    components: {
      headTop,
      'v-footer': Footer
    },
    created () {
      bus.$on('passNameTel', (realName, phoneNumber) => {
        this.realName = realName
        this.phoneNumber = phoneNumber
      })
      this._getMyInfo()
    },
    methods: {
      // 头像资料数据
      _getMyInfo () {
        getMyInfo().then(res => {
          if (res.code === 200) {
            this.info = res.data
            const phoneName = {
              phone: res.data.phone,
              name: res.data.real_name
            }
            savePhoneName(phoneName)
          }
        })
      }
    }
  }
</script>
